<link rel="stylesheet" href="__CDN__/assets/element-ui-2.15.14/css/index.css">
<link rel="stylesheet" href="__CDN__/assets/css/vvv.css">
<style>
    .el-form-item__label {
        width: 120px !important;
    }

    .el-tag + .el-tag {
        margin-left: 10px;
    }

    .button-new-tag {
        margin-left: 10px;
        height: 32px;
        line-height: 30px;
        padding-top: 0;
        padding-bottom: 0;
    }

    .input-new-tag {
        width: 90px;
        margin-left: 10px;
        vertical-align: bottom;
    }

    input[type="file"] {
        display: none !important;
    }

    .el-form-item__error {
        margin-left: 30px;
    }

    .search-select .el-select .el-input__inner {
        width: 130px;
    }

    .key .el-input__inner {
        /*width: 240px !important;*/
    }

    .vue-table {
        padding: 0;
    }
</style>
<div id="vue" v-cloak>
    <div class="screen-container">
        <div class="screen-container-show">
            <div class="screen-container-left display-flex">
                <el-button size="small" @click="refreshPage" icon="el-icon-refresh" circle type="primary"></el-button>
                <div class="datetime">
                    <el-date-picker
                            v-model="search.startTime"
                            type="datetime"
                            placeholder="选择起始时间">
                    </el-date-picker>
                </div>
                <div class="datetime">
                    <el-date-picker
                            v-model="search.endTime"
                            type="datetime"
                            placeholder="选择结束时间">
                    </el-date-picker>
                </div>
            </div>
            <div class="search-select screen-container-right display-flex keyword v-china">
                <el-cascader
                        @change="handleNavChange"
                        :options="navList"
                        :props="{ checkStrictly: true }"
                        clearable
                        placeholder="选择所属分类"
                        filterable
                        v-model="search.nav"
                >
                </el-cascader>
            </div>
            <div class="search-select screen-container-right display-flex keyword">
                <el-select v-model="search.typeIndex" @clear="handleClearSelect('typeIndex')" clearable placeholder="文件类型">
                    <el-option
                            v-for="item in typeList"
                            :key="item.index"
                            :label="item.name"
                            :value="item.index">
                    </el-option>
                </el-select>
            </div>
            <div class="search-select screen-container-right display-flex keyword key">
                <el-input @clear="handleClearSearchInp" clearable v-model="search.keyword" placeholder="请输入您要搜索的内容">
                    <el-select v-model="search.type" filterable clearable slot="prepend" placeholder="请选择">
                        <el-option v-for="(item, index) in searchOpt" :label="item.value"
                                   :value="item.id">
                        </el-option>
                    </el-select>
                    <el-button slot="append" @click="searchData" icon="el-icon-search"></el-button>
                </el-input>
            </div>
            <div class="screen-container-right display-flex keyword">
                <el-upload
                        style="margin-right: 10px;"
                        class="upload-img"
                        :data="{nav: search.nav}"
                        :multiple="true"
                        :show-file-list="false"
                        :before-upload="beforeFileUpload"
                        :on-success="uploadFileSuccess"
                        accept=".jpg,.jpeg,.gif,.png"
                        action="{:url('ajax/upload')}"
                >
                    <el-button size="small" type="primary" plain icon="el-icon-upload">上传
                    </el-button>
                </el-upload>
                <el-button size="small" @click="handleNavDialog" type="warning" plain icon="el-icon-right">归类
                </el-button>
                <el-button size="small" @click="del" type="danger" plain icon="el-icon-delete">删除
                </el-button>
                <el-button size="small" @click="handleOpenNav" type="success" plain icon="el-icon-menu">分类管理
                </el-button>
            </div>
        </div>
    </div>
    <div class="vue-table background-white color-666">
        <el-table
                :data="tableData"
                border
                highlight-current-row v-loading="listLoading"
                element-loading-text="拼命加载中..."
                @selection-change="handleSelectionChange"
                @sort-change="handleTableFieldSort"
                style="width: 100%"
        >
            <el-table-column type="selection" width="60" align="center"></el-table-column>
            <el-table-column prop="id" width="80" label="ID" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="category" width="200" label="所属分类" show-overflow-tooltip
                             align="center">
                <template scope="scope">
                    <span>{{scope.row.nav_name}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="image" label="图片" width="100" align="center">
                <template scope="scope">
                    <a style="cursor: pointer;" :href="scope.row.url" target="_blank">
                        <img :src="scope.row.url" style="border-radius: 10px;width: 50px;height: 50px;padding: 5px">
                    </a>
                </template>
            </el-table-column>
            <el-table-column prop="filename" sortable="custom" width="220" label="文件名" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="imagewidth" width="100" label="宽" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="imageheight" width="100" label="高" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="mimetype" width="110" label="文件类型" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="imagetype" width="110" label="图片类型" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="storage" width="110" label="存储类型" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column prop="createtime" sortable="custom" width="160" :formatter="dateFormat" label="创建日期" show-overflow-tooltip
                             align="center"></el-table-column>
            <el-table-column align="center" width="130" fixed="right" label="操作">
                <template scope="scope">
                    <button @click="dell(scope.row.id)" type="button"
                            class="el-button el-button--danger el-button--small"><i
                            class="el-icon-delete"></i><span>删除</span></button>
                </template>
            </el-table-column>
        </el-table>
        <div class="layout-pagination">
            <el-pagination
                    background
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[10, 20, 50, 100]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="totalCount">
            </el-pagination>
        </div>
    </div>

    <!-- 归类 -->
    <div class="nav-dialog">
        <el-dialog
                :close-on-click-modal="false"
                title="归类"
                :visible.sync="navDialog"
                width="40%"
        >
            <div class="form">
                <el-form ref="form" :model="formData" label-width="90px">
                    <el-form-item label="所属分类：" prop="pid">
                        <el-cascader
                                style="width: 330px;"
                                :options="navList"
                                :props="{ checkStrictly: true }"
                                clearable
                                placeholder="选择所属分类"
                                filterable
                                v-model="formData.nav"
                        >
                        </el-cascader>
                    </el-form-item>
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="navDialog = false" size="small" icon="el-icon-switch-button">取 消</el-button>
                <el-button type="primary" size="small" @click="submitNav" icon="el-icon-position">提 交</el-button>
            </span>
        </el-dialog>
    </div>
</div>

<script src="__CDN__/assets/element-ui-2.15.14/js/vue.js"></script>
<script src="__CDN__/assets/element-ui-2.15.14/js/index.js"></script>
<script src="__CDN__/assets/tool/libs/moment.js"></script>
<script src="__CDN__/assets/js/jquery-2.1.1.min.js"></script>